###FIRST RUN Study 1 Data Code.R###

####TABLE 1####
table1 <- matrix(NA,16,3)
table1[1,1] <- mean(study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[1,2] <- mean(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[1,3] <- table1[1,2] - table1[1,1]
table1[2,1] <- sum(table(study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"]))
table1[2,2] <- sum(table(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"]))
table1[2,3] <- as.numeric(t.test(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"],study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"])[3])

table1[3,1] <- mean(study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "LAW"],na.rm=T)
table1[3,2] <- mean(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "LAW"],na.rm=T)
table1[3,3] <- table1[3,2] - table1[3,1]
table1[4,1] <- sum(table(study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "LAW"]))
table1[4,2] <- sum(table(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "LAW"]))
table1[4,3] <- as.numeric(t.test(study1$CB_FED_SQ[study1$CB_FED_TREAT==1 & study1$CONDITION == "LAW"],study1$CB_FED_SQ[study1$CB_FED_TREAT==0 & study1$CONDITION == "LAW"])[3])

table1[5,1] <- mean(study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[5,2] <- mean(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[5,3] <- table1[5,2] - table1[5,1]
table1[6,1] <- sum(table(study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"]))
table1[6,2] <- sum(table(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"]))
table1[6,3] <- as.numeric(t.test(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"],study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"])[3])

table1[7,1] <- mean(study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "LAW"],na.rm=T)
table1[7,2] <- mean(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "LAW"],na.rm=T)
table1[7,3] <- table1[7,2] - table1[7,1]
table1[8,1] <- sum(table(study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "LAW"]))
table1[8,2] <- sum(table(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "LAW"]))
table1[8,3] <- as.numeric(t.test(study1$CB_ST_SQ[study1$CB_ST_TREAT==1 & study1$CONDITION == "LAW"],study1$CB_ST_SQ[study1$CB_ST_TREAT==0 & study1$CONDITION == "LAW"])[3])

table1[9,1] <- mean(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[9,2] <- mean(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[9,3] <- table1[9,2] - table1[9,1]
table1[10,1] <- sum(table(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"]))
table1[10,2] <- sum(table(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"]))
table1[10,3] <- as.numeric(t.test(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "CONSTITUTION"],study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "CONSTITUTION"])[3])

table1[11,1] <- mean(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "LAW"],na.rm=T)
table1[11,2] <- mean(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "LAW"],na.rm=T)
table1[11,3] <- table1[11,2] - table1[11,1]
table1[12,1] <- sum(table(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "LAW"]))
table1[12,2] <- sum(table(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "LAW"]))
table1[12,3] <- as.numeric(t.test(study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==1 & study1$CONDITION == "LAW"],study1$MAJ_FED_SQ[study1$MAJ_FED_TREAT==0 & study1$CONDITION == "LAW"])[3])

table1[13,1] <- mean(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[13,2] <- mean(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"],na.rm=T)
table1[13,3] <- table1[13,2] - table1[13,1]
table1[14,1] <- sum(table(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"]))
table1[14,2] <- sum(table(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"]))
table1[14,3] <- as.numeric(t.test(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "CONSTITUTION"],study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "CONSTITUTION"])[3])

table1[15,1] <- mean(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "LAW"],na.rm=T)
table1[15,2] <- mean(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "LAW"],na.rm=T)
table1[15,3] <- table1[15,2] - table1[15,1]
table1[16,1] <- sum(table(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "LAW"]))
table1[16,2] <- sum(table(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "LAW"]))
table1[16,3] <- as.numeric(t.test(study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==1 & study1$CONDITION == "LAW"],study1$MAJ_ST_SQ[study1$MAJ_ST_TREAT==0 & study1$CONDITION == "LAW"])[3])
###############